namespace utils {

	export function angleOfPoints(x1: number, y1: number, x2: number, y2: number): number;
	export function angleOfPoints(pa: egret.Point, pb: egret.Point): number;
	export function angleOfPoints(p1: number | egret.Point, p2: number | egret.Point, p3?: number, p4?: number): number {
		if (p1 instanceof egret.Point && p2 instanceof egret.Point) return Math.radianToAngle(Math.atan2(p2.y - p1.y, p2.x - p1.x));
		else if (numeric(p3) && numeric(p4)) return Math.radianToAngle(Math.atan2(p4 - <number>p2, p3 - <number>p1));
	}

	export function angleOfLines(la: hjc.Line, lb: hjc.Line): number {
		//todo
		return 0;
	}

	export function disOfPoints(pa: egret.Point, pb: egret.Point): number;
	export function disOfPoints(x1: number, y1: number, x2: number, y2: number): number;
	export function disOfPoints(p1: number | egret.Point, p2: number | egret.Point, p3?: number, p4?: number): number {
		if (p1 instanceof egret.Point && p2 instanceof egret.Point) {
			return Math.sqrt(Math.pow(p1.x - p2.x, 2) + Math.pow(p1.y - p2.y, 2));
		} else if (numeric(p3) && numeric(p4)) {
			return Math.sqrt(Math.pow(p1 as number - p3 as number, 2) + Math.pow(p2 as number - p4 as number, 2));
		}
		console.warn('点距离运算参数错误'); return 0;
	}

	export function disOfLines(la: hjc.Line, lb: hjc.Line): number {
		//todo
		return 0;
	}
	export function absDisBetween(obj1: egret.DisplayObject, obj2: egret.DisplayObject): number {
		let p: egret.Point = obj1.localToGlobal(0, 0);
		p = obj2.globalToLocal(p.x, p.y);
		return disOfPoints(0, 0, p.x, p.y);
	}

	export function angleToDir8(angle: number): hjc.Dir8 {
		return Math.floor((angle + 22.5) / 45 + 10) % 8;
	}
}